<template>
  <transition name="fade">
    <div class="tool-dialog-wrapper" v-show="show">
    <div class="tool-dialog" :style="{ marginTop: top }">
      <!-- 标题 -->
      <div class="tool-dialog-title">
        <div class="tool-dialog-title-name">{{title}}</div>
        <div class="tool-dialog-title-close" @click="close">
          <icon-font name="plus" class="tool-dialog-close-icon"></icon-font>
        </div>
      </div>
      <!-- 内容 -->
      <div class="tool-dialog-content">
        <slot></slot>
      </div>
    </div>
  </div>
  </transition>
</template>

<script>
export default {
  props: {
    value: Boolean,
    title: String,
    // 距离顶部距离
    top: {
      type: String,
      default: '15vh'
    }
  },
  computed: {
    show: {
      get () {
        return this.value
      },
      set (val) {
        this.$emit('input', val)
      }
    }
  },
  methods: {
    close () {
      this.show = false
    }
  }
}
</script>

<style lang="scss">
.tool-dialog-wrapper{
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: auto;
  z-index: 999;
  background: rgba(0, 0, 0, 0.3);
}
.tool-dialog{
  margin: 15vh auto 0;
  width: 50%;
  min-height: 100px;
  min-width: 100px;
  box-sizing: border-box;
  background: #fff;
  border-radius: 2px;
}
.tool-dialog-title{
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  font-size: 16px;
  padding-left: 20px;
  background: $theme-color;
}
.tool-dialog-title-name{
  color: #fff;
}
.tool-dialog-title-close{
  margin-right: 20px;
}
.tool-dialog-close-icon{
  color: #fff;
  transform: rotate(45deg);
  cursor: pointer;
}
.tool-dialog-content{
  padding: 20px;
  box-sizing: border-box;
}
</style>